package com.ruoyi.system.service;

import com.ruoyi.system.domain.Dept;
import jxl.Workbook;
import jxl.format.UnderlineStyle;
import jxl.write.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;

@Service
public class DaochuService {

    @Autowired
    private IDeptService deptService;


    public void deptxinxi(Dept dept,HttpServletResponse response){

        response.reset();
        response.setContentType("application/x-download;charset=utf-8");

        List<Map<String,Object>> list = deptService.CustomList(dept);
        OutputStream os=null;
        WritableWorkbook wbook=null;
        try
        {
            os = new BufferedOutputStream(response.getOutputStream());//得到输出流的语句
            //response.getOutputStream();// 取得输出流
            response.reset();// 清空输出流
            String wenjiantitle = "下级单位汇总表"; //文件名
            String tmptitle = "下级单位汇总表"; // 标题

            response.setHeader("Content-disposition", "attachment; filename="+new String(wenjiantitle.getBytes(),"iso8859-1")+".xls");// 设定输出文件头
            response.setContentType("application/vnd.ms-excel");// 定义输出类型
            wbook = Workbook.createWorkbook(os); // 建立excel文件
            WritableSheet wsheet = wbook.createSheet(tmptitle, 0); // sheet名称
            // 设置excel标题
            WritableFont wfont = new WritableFont(WritableFont.ARIAL, 20,WritableFont.BOLD,false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK); //设置表格样式

            WritableCellFormat wcfFC = new WritableCellFormat(wfont);
            wcfFC.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN); // 添加边框
            wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);   //设置居中对齐
            wcfFC.setAlignment(Alignment.CENTRE);
            //wcfFC.setBackground(Colour.AQUA);
            Label label=new Label(0, 0, tmptitle, wcfFC);
            WritableCellFormat cellFormat=new WritableCellFormat();
            cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
            cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
            cellFormat.setWrap(true);
            //cellFormat.setBackground(Colour.AQUA);
            cellFormat.setFont(wfont);
            label.setCellFormat(cellFormat);
            wsheet.addCell(label);
            wsheet.addCell(new Label(0, 0, tmptitle, wcfFC));
            /*wsheet.addCell(new Label(7, 0, tmptitle, wcfFC));*/
            wsheet.setRowView(0,500); //第一行高度
            wsheet.setRowView(1,500); //第二行高度
            wsheet.mergeCells(0, 0, 9, 0);  //合并单元格(第一列的第一行和第二十三列的第二行合并)
            wsheet.setColumnView(0,25); //宽度
            wsheet.setColumnView(1,25); //宽度
            wsheet.setColumnView(2,25); //宽度
            wsheet.setColumnView(3,25); //宽度
            wsheet.setColumnView(4,25); //宽度
            wsheet.setColumnView(5,25); //宽度
            wsheet.setColumnView(6,25); //宽度
            wsheet.setColumnView(7,25); //宽度
            wsheet.setColumnView(8,25); //宽度
            wsheet.setColumnView(9,25); //宽度

            // 开始生成主体内容
            wfont = new WritableFont(WritableFont.ARIAL, 12,WritableFont.BOLD,false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
            wcfFC = new WritableCellFormat(wfont);
            wcfFC.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
            wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);   //设置居中对齐
            wcfFC.setAlignment(Alignment.CENTRE);
            wcfFC.setWrap(true);
            wsheet.addCell(new Label(0, 1, "序号",wcfFC));
            wsheet.addCell(new Label(1, 1, "特贴单位",wcfFC));
            wsheet.addCell(new Label(2, 1, "单位类型",wcfFC));
            wsheet.addCell(new Label(3, 1, "地区",wcfFC));
            wsheet.addCell(new Label(4, 1, "负责人",wcfFC));
            wsheet.addCell(new Label(5, 1, "负责人电话",wcfFC));
            wsheet.addCell(new Label(6, 1, "负责人手机",wcfFC));
            wsheet.addCell(new Label(7, 1, "单位状态",wcfFC));
            wsheet.addCell(new Label(8, 1, "管理部门",wcfFC));
            wsheet.addCell(new Label(9, 1, "地址",wcfFC));

            // 表头结束
            wfont = new WritableFont(WritableFont.ARIAL, 12,WritableFont.NO_BOLD,false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
            wcfFC = new WritableCellFormat(wfont);
            wcfFC.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
            wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);   //设置居中对齐
            wcfFC.setAlignment(Alignment.CENTRE);
            wcfFC.setWrap(true);
            int geshu = 0;
            for (int i = 0; i < list.size(); i++) {
                Map<String,Object> mmMap = list.get(i);
                String deptname = mmMap.get("deptname") == null ?"": mmMap.get("deptname").toString();
                String deptlevel_text = mmMap.get("deptlevel_text") == null ?"": mmMap.get("deptlevel_text").toString();
                String status = mmMap.get("status") == null ?"": mmMap.get("status").toString();
                String shengfen_text= mmMap.get("shengfen_text") == null ?"": mmMap.get("shengfen_text").toString();
                String fuzerenbangongdianhua= mmMap.get("fuzerenbangongdianhua") == null ?"": mmMap.get("fuzerenbangongdianhua").toString();
                String fuzerenshouji= mmMap.get("fuzerenshouji") == null ?"": mmMap.get("fuzerenshouji").toString();
                String guanlibumen= mmMap.get("guanlibumen") == null ?"": mmMap.get("guanlibumen").toString();
                String dizhi= mmMap.get("dizhi") == null ?"": mmMap.get("dizhi").toString();
                String fuzeren= mmMap.get("fuzeren") == null ?"": mmMap.get("fuzeren").toString();
                if(status.equals("1")){
                    status ="正常";
                }else{
                    status ="注销";
                }

                wsheet.addCell(new Label(0, 2+geshu, String.valueOf(1+geshu),wcfFC));
                wsheet.addCell(new Label(1, 2+geshu,deptname,wcfFC));
                wsheet.addCell(new Label(2, 2+geshu,deptlevel_text,wcfFC));
                wsheet.addCell(new Label(3, 2+geshu,shengfen_text,wcfFC));
                wsheet.addCell(new Label(4, 2+geshu,fuzeren,wcfFC));
                wsheet.addCell(new Label(5, 2+geshu,fuzerenbangongdianhua ,wcfFC));
                wsheet.addCell(new Label(6, 2+geshu,fuzerenshouji ,wcfFC));
                wsheet.addCell(new Label(7, 2+geshu,status,wcfFC));
                wsheet.addCell(new Label(8, 2+geshu,guanlibumen ,wcfFC));
                wsheet.addCell(new Label(9, 2+geshu,dizhi,wcfFC));
                geshu = geshu+1;
            }
            wbook.write(); // 写入文件
            wbook.close();
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }finally{
            if(os!=null){
                try {
                    os.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }


    public void zhuanjiaxinxi(List<Map<String,Object>> list,HttpServletResponse response){

        response.reset();
        response.setContentType("application/x-download;charset=utf-8");
        OutputStream os=null;
        WritableWorkbook wbook=null;
        try
        {
            os = new BufferedOutputStream(response.getOutputStream());//得到输出流的语句
            //response.getOutputStream();// 取得输出流
            response.reset();// 清空输出流
            String wenjiantitle = "专家信息汇总表"; //文件名
            String tmptitle = "专家信息汇总表"; // 标题

            response.setHeader("Content-disposition", "attachment; filename="+new String(wenjiantitle.getBytes(),"iso8859-1")+".xls");// 设定输出文件头
            response.setContentType("application/vnd.ms-excel");// 定义输出类型
            wbook = Workbook.createWorkbook(os); // 建立excel文件
            WritableSheet wsheet = wbook.createSheet(tmptitle, 0); // sheet名称
            // 设置excel标题
            WritableFont wfont = new WritableFont(WritableFont.ARIAL, 20,WritableFont.BOLD,false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK); //设置表格样式

            WritableCellFormat wcfFC = new WritableCellFormat(wfont);
            wcfFC.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN); // 添加边框
            wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);   //设置居中对齐
            wcfFC.setAlignment(Alignment.CENTRE);
            //wcfFC.setBackground(Colour.AQUA);
            Label label=new Label(0, 0, tmptitle, wcfFC);
            WritableCellFormat cellFormat=new WritableCellFormat();
            cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
            cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
            cellFormat.setWrap(true);
            //cellFormat.setBackground(Colour.AQUA);
            cellFormat.setFont(wfont);
            label.setCellFormat(cellFormat);
            wsheet.addCell(label);
            wsheet.addCell(new Label(0, 0, tmptitle, wcfFC));
            /*wsheet.addCell(new Label(7, 0, tmptitle, wcfFC));*/
            wsheet.setRowView(0,500); //第一行高度
            wsheet.setRowView(1,500); //第二行高度
            wsheet.mergeCells(0, 0, 7, 0);  //合并单元格(第一列的第一行和第二十三列的第二行合并)
            wsheet.setColumnView(0,25); //宽度
            wsheet.setColumnView(1,25); //宽度
            wsheet.setColumnView(2,25); //宽度
            wsheet.setColumnView(3,25); //宽度
            wsheet.setColumnView(4,25); //宽度
            wsheet.setColumnView(5,25); //宽度
            wsheet.setColumnView(6,25); //宽度
            wsheet.setColumnView(7,25); //宽度

            // 开始生成主体内容
            wfont = new WritableFont(WritableFont.ARIAL, 12,WritableFont.BOLD,false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
            wcfFC = new WritableCellFormat(wfont);
            wcfFC.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
            wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);   //设置居中对齐
            wcfFC.setAlignment(Alignment.CENTRE);
            wcfFC.setWrap(true);
            wsheet.addCell(new Label(0, 1, "序号",wcfFC));
            wsheet.addCell(new Label(1, 1, "专家姓名",wcfFC));
            wsheet.addCell(new Label(2, 1, "特贴单位",wcfFC));
            wsheet.addCell(new Label(3, 1, "特贴单位层级",wcfFC));
            wsheet.addCell(new Label(4, 1, "工作单位",wcfFC));
            wsheet.addCell(new Label(5, 1, "入选年份",wcfFC));
            wsheet.addCell(new Label(6, 1, "专家状态",wcfFC));
            wsheet.addCell(new Label(7, 1, "状态变动时间",wcfFC));

            // 表头结束
            wfont = new WritableFont(WritableFont.ARIAL, 12,WritableFont.NO_BOLD,false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
            wcfFC = new WritableCellFormat(wfont);
            wcfFC.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
            wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);   //设置居中对齐
            wcfFC.setAlignment(Alignment.CENTRE);
            wcfFC.setWrap(true);
            int geshu = 0;
            for (int i = 0; i < list.size(); i++) {
                Map<String,Object> mmMap = list.get(i);
                String xingming = mmMap.get("xingming") == null ?"": mmMap.get("xingming").toString();
                String deptname = mmMap.get("deptname") == null ?"": mmMap.get("deptname").toString();
                String deptlevel_text = mmMap.get("deptlevel_text") == null ?"": mmMap.get("deptlevel_text").toString();
                String gongzuodanwei= mmMap.get("gongzuodanwei") == null ?"": mmMap.get("gongzuodanwei").toString();
                String ruxuannianfen= mmMap.get("ruxuannianfen") == null ?"": mmMap.get("ruxuannianfen").toString();
                String zhuanjiazhuangtai_text= mmMap.get("zhuanjiazhuangtai_text") == null ?"": mmMap.get("zhuanjiazhuangtai_text").toString();
                String zhuangtaibiandongshijian= mmMap.get("zhuangtaibiandongshijian") == null ?"": mmMap.get("zhuangtaibiandongshijian").toString();

                wsheet.addCell(new Label(0, 2+geshu, String.valueOf(1+geshu),wcfFC));
                wsheet.addCell(new Label(1, 2+geshu,xingming,wcfFC));
                wsheet.addCell(new Label(2, 2+geshu,deptname,wcfFC));
                wsheet.addCell(new Label(3, 2+geshu,deptlevel_text,wcfFC));
                wsheet.addCell(new Label(4, 2+geshu,gongzuodanwei,wcfFC));
                wsheet.addCell(new Label(5, 2+geshu,ruxuannianfen ,wcfFC));
                wsheet.addCell(new Label(6, 2+geshu,zhuanjiazhuangtai_text ,wcfFC));
                wsheet.addCell(new Label(7, 2+geshu,zhuangtaibiandongshijian,wcfFC));

                geshu = geshu+1;
            }
            wbook.write(); // 写入文件
            wbook.close();
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }finally{
            if(os!=null){
                try {
                    os.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }

    public void bdshenbaoxinxi(List<Map<String,Object>> list,HttpServletResponse response){

        response.reset();
        response.setContentType("application/x-download;charset=utf-8");
        OutputStream os=null;
        WritableWorkbook wbook=null;
        try
        {
            os = new BufferedOutputStream(response.getOutputStream());//得到输出流的语句
            //response.getOutputStream();// 取得输出流
            response.reset();// 清空输出流
            String wenjiantitle = "变动申报信息汇总表"; //文件名
            String tmptitle = "变动申报信息汇总表"; // 标题

            response.setHeader("Content-disposition", "attachment; filename="+new String(wenjiantitle.getBytes(),"iso8859-1")+".xls");// 设定输出文件头
            response.setContentType("application/vnd.ms-excel");// 定义输出类型
            wbook = Workbook.createWorkbook(os); // 建立excel文件
            WritableSheet wsheet = wbook.createSheet(tmptitle, 0); // sheet名称
            // 设置excel标题
            WritableFont wfont = new WritableFont(WritableFont.ARIAL, 20,WritableFont.BOLD,false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK); //设置表格样式

            WritableCellFormat wcfFC = new WritableCellFormat(wfont);
            wcfFC.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN); // 添加边框
            wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);   //设置居中对齐
            wcfFC.setAlignment(Alignment.CENTRE);
            //wcfFC.setBackground(Colour.AQUA);
            Label label=new Label(0, 0, tmptitle, wcfFC);
            WritableCellFormat cellFormat=new WritableCellFormat();
            cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
            cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
            cellFormat.setWrap(true);
            //cellFormat.setBackground(Colour.AQUA);
            cellFormat.setFont(wfont);
            label.setCellFormat(cellFormat);
            wsheet.addCell(label);
            wsheet.addCell(new Label(0, 0, tmptitle, wcfFC));
            /*wsheet.addCell(new Label(7, 0, tmptitle, wcfFC));*/
            wsheet.setRowView(0,500); //第一行高度
            wsheet.setRowView(1,500); //第二行高度
            wsheet.mergeCells(0, 0, 4, 0);  //合并单元格(第一列的第一行和第二十三列的第二行合并)
            wsheet.setColumnView(0,25); //宽度
            wsheet.setColumnView(1,25); //宽度
            wsheet.setColumnView(2,25); //宽度
            wsheet.setColumnView(3,25); //宽度
            wsheet.setColumnView(4,25); //宽度
//            wsheet.setColumnView(5,25); //宽度
//            wsheet.setColumnView(6,25); //宽度

            // 开始生成主体内容
            wfont = new WritableFont(WritableFont.ARIAL, 12,WritableFont.BOLD,false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
            wcfFC = new WritableCellFormat(wfont);
            wcfFC.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
            wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);   //设置居中对齐
            wcfFC.setAlignment(Alignment.CENTRE);
            wcfFC.setWrap(true);
            wsheet.addCell(new Label(0, 1, "序号",wcfFC));
            wsheet.addCell(new Label(1, 1, "专家姓名",wcfFC));
            wsheet.addCell(new Label(2, 1, "工作单位",wcfFC));
            wsheet.addCell(new Label(3, 1, "变动类型",wcfFC));
            wsheet.addCell(new Label(4, 1, "变动时间",wcfFC));
//            wsheet.addCell(new Label(5, 1, "审核时间",wcfFC));
//            wsheet.addCell(new Label(6, 1, "最新状态",wcfFC));


            // 表头结束
            wfont = new WritableFont(WritableFont.ARIAL, 12,WritableFont.NO_BOLD,false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
            wcfFC = new WritableCellFormat(wfont);
            wcfFC.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
            wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);   //设置居中对齐
            wcfFC.setAlignment(Alignment.CENTRE);
            wcfFC.setWrap(true);
            int geshu = 0;
            for (int i = 0; i < list.size(); i++) {
                Map<String,Object> mmMap = list.get(i);
                String xingming = mmMap.get("xingming") == null ?"": mmMap.get("xingming").toString();
                String tjdeptname = mmMap.get("gongzuodanwei") == null ?"": mmMap.get("gongzuodanwei").toString();
                String biandongleixing_txt = mmMap.get("biandongleixing_text") == null ?"": mmMap.get("biandongleixing_text").toString();
                String renwuxiafashijian= mmMap.get("biandongshijian") == null ?"": mmMap.get("biandongshijian").toString();
//                String renwuwanchengshijian= mmMap.get("renwuwanchengshijian") == null ?"": mmMap.get("renwuwanchengshijian").toString();
//                String zxdeptname= mmMap.get("zxdeptname") == null ?"": mmMap.get("zxdeptname").toString();
//                String zuixinzhuangtai= mmMap.get("zuixinzhuangtai") == null ?"": mmMap.get("zuixinzhuangtai").toString();

                wsheet.addCell(new Label(0, 2+geshu, String.valueOf(1+geshu),wcfFC));
                wsheet.addCell(new Label(1, 2+geshu,xingming,wcfFC));
                wsheet.addCell(new Label(2, 2+geshu,tjdeptname,wcfFC));
                wsheet.addCell(new Label(3, 2+geshu,biandongleixing_txt,wcfFC));
                wsheet.addCell(new Label(4, 2+geshu,renwuxiafashijian,wcfFC));
//                wsheet.addCell(new Label(5, 2+geshu,renwuwanchengshijian ,wcfFC));
//                wsheet.addCell(new Label(6, 2+geshu,zxdeptname+zuixinzhuangtai ,wcfFC));

                geshu = geshu+1;
            }
            wbook.write(); // 写入文件
            wbook.close();
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }finally{
            if(os!=null){
                try {
                    os.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }

    public void bdshenhexinxi(List<Map<String,Object>> list,HttpServletResponse response){

        response.reset();
        response.setContentType("application/x-download;charset=utf-8");
        OutputStream os=null;
        WritableWorkbook wbook=null;
        try
        {
            os = new BufferedOutputStream(response.getOutputStream());//得到输出流的语句
            //response.getOutputStream();// 取得输出流
            response.reset();// 清空输出流
            String wenjiantitle = "变动审核信息汇总表"; //文件名
            String tmptitle = "变动审核信息汇总表"; // 标题

            response.setHeader("Content-disposition", "attachment; filename="+new String(wenjiantitle.getBytes(),"iso8859-1")+".xls");// 设定输出文件头
            response.setContentType("application/vnd.ms-excel");// 定义输出类型
            wbook = Workbook.createWorkbook(os); // 建立excel文件
            WritableSheet wsheet = wbook.createSheet(tmptitle, 0); // sheet名称
            // 设置excel标题
            WritableFont wfont = new WritableFont(WritableFont.ARIAL, 20,WritableFont.BOLD,false, UnderlineStyle.NO_UNDERLINE, Colour.BLACK); //设置表格样式

            WritableCellFormat wcfFC = new WritableCellFormat(wfont);
            wcfFC.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN); // 添加边框
            wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);   //设置居中对齐
            wcfFC.setAlignment(Alignment.CENTRE);
            //wcfFC.setBackground(Colour.AQUA);
            Label label=new Label(0, 0, tmptitle, wcfFC);
            WritableCellFormat cellFormat=new WritableCellFormat();
            cellFormat.setAlignment(jxl.format.Alignment.CENTRE);
            cellFormat.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE);
            cellFormat.setWrap(true);
            //cellFormat.setBackground(Colour.AQUA);
            cellFormat.setFont(wfont);
            label.setCellFormat(cellFormat);
            wsheet.addCell(label);
            wsheet.addCell(new Label(0, 0, tmptitle, wcfFC));
            /*wsheet.addCell(new Label(7, 0, tmptitle, wcfFC));*/
            wsheet.setRowView(0,500); //第一行高度
            wsheet.setRowView(1,500); //第二行高度
            wsheet.mergeCells(0, 0, 6, 0);  //合并单元格(第一列的第一行和第二十三列的第二行合并)
            wsheet.setColumnView(0,25); //宽度
            wsheet.setColumnView(1,25); //宽度
            wsheet.setColumnView(2,25); //宽度
            wsheet.setColumnView(3,25); //宽度
            wsheet.setColumnView(4,25); //宽度
            wsheet.setColumnView(5,25); //宽度
            wsheet.setColumnView(6,25); //宽度

            // 开始生成主体内容
            wfont = new WritableFont(WritableFont.ARIAL, 12,WritableFont.BOLD,false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
            wcfFC = new WritableCellFormat(wfont);
            wcfFC.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
            wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);   //设置居中对齐
            wcfFC.setAlignment(Alignment.CENTRE);
            wcfFC.setWrap(true);
            wsheet.addCell(new Label(0, 1, "序号",wcfFC));
            wsheet.addCell(new Label(1, 1, "专家姓名",wcfFC));
            wsheet.addCell(new Label(2, 1, "特贴单位",wcfFC));
            wsheet.addCell(new Label(3, 1, "变动类型",wcfFC));
            wsheet.addCell(new Label(4, 1, "提交时间",wcfFC));
            wsheet.addCell(new Label(5, 1, "审核时间",wcfFC));
            wsheet.addCell(new Label(6, 1, "最新状态",wcfFC));


            // 表头结束
            wfont = new WritableFont(WritableFont.ARIAL, 12,WritableFont.NO_BOLD,false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
            wcfFC = new WritableCellFormat(wfont);
            wcfFC.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);
            wcfFC.setVerticalAlignment(VerticalAlignment.CENTRE);   //设置居中对齐
            wcfFC.setAlignment(Alignment.CENTRE);
            wcfFC.setWrap(true);
            int geshu = 0;
            for (int i = 0; i < list.size(); i++) {
                Map<String,Object> mmMap = list.get(i);
                String xingming = mmMap.get("xingming") == null ?"": mmMap.get("xingming").toString();
                String tjdeptname = mmMap.get("tjdeptname") == null ?"": mmMap.get("tjdeptname").toString();
                String biandongleixing_txt = mmMap.get("biandongleixing_txt") == null ?"": mmMap.get("biandongleixing_txt").toString();
                String renwuxiafashijian= mmMap.get("renwuxiafashijian") == null ?"": mmMap.get("renwuxiafashijian").toString();
                String renwuwanchengshijian= mmMap.get("renwuwanchengshijian") == null ?"": mmMap.get("renwuwanchengshijian").toString();
                String zxdeptname= mmMap.get("zxdeptname") == null ?"": mmMap.get("zxdeptname").toString();
                String zuixinzhuangtai= mmMap.get("zuixinzhuangtai") == null ?"": mmMap.get("zuixinzhuangtai").toString();

                wsheet.addCell(new Label(0, 2+geshu, String.valueOf(1+geshu),wcfFC));
                wsheet.addCell(new Label(1, 2+geshu,xingming,wcfFC));
                wsheet.addCell(new Label(2, 2+geshu,tjdeptname,wcfFC));
                wsheet.addCell(new Label(3, 2+geshu,biandongleixing_txt,wcfFC));
                wsheet.addCell(new Label(4, 2+geshu,renwuxiafashijian,wcfFC));
                wsheet.addCell(new Label(5, 2+geshu,renwuwanchengshijian ,wcfFC));
                wsheet.addCell(new Label(6, 2+geshu,zxdeptname+zuixinzhuangtai ,wcfFC));

                geshu = geshu+1;
            }
            wbook.write(); // 写入文件
            wbook.close();
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }finally{
            if(os!=null){
                try {
                    os.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
    }



}
